<include file="Public:header" />
<form class="form-inline definewidth m20" action="{:U('Contract/Index')}" method="get">
    合同编号：
    <input type="text" name="contract_id" id="contract_id" class="abc input-default" placeholder="" value="{$contract_id}">&nbsp;&nbsp;
    企业名称：
    <input type="text" name="company_name" id="company_name" class="abc input-default" placeholder="" value="{$company_name}">&nbsp;&nbsp;
    签订时间：
    <input type="date" name="make_time" id="make_time" class="abc input-default" placeholder="" value="{$make_time}">&nbsp;&nbsp;
    合同截至日期：
    <input type="date" name="end_time" id="end_time" class="abc input-default" placeholder="" value="{$end_time}">&nbsp;&nbsp;
    <button type="submit" class="btn btn-primary" >查询</button>&nbsp;&nbsp; <button type="button" class="btn btn-success" id="addnew">新增合同</button>
</form>
<table class="table table-bordered table-hover definewidth m10">
    <thead>
    <tr>
        <th></th>
        <th>合同编号</th>
        <th>企业名称</th>
        <th>合同金额</th>
        <th>签订日期</th>
        <th>合同截至日期</th>
        <th>合同内容</th>
        <th>操作</th>
    </tr>
    </thead>
    <foreach name="list" item="l_val" key="k">
        <tr>
            <td>{$k+1}</td>
            <td>{$l_val.contract_id}</td>
            <td>{$l_val.company_name}</td>
            <td>￥{$l_val.amount}</td>
            <td>{$l_val.make_time|date='Y-m-d',###}</td>
            <td>{$l_val.end_time|date='Y-m-d',###}</td>
            <td>{$l_val.content}</td>
            <td>
                <a href="{:U('Contract/view',array('cid'=>$l_val['contract_id']))}" title="查看" ><icon class="icon-eye-open" ></icon></a>
                <a href="{:U('Contract/edit',array('cid'=>$l_val['contract_id']))}" title="编辑" ><icon class="icon-edit" ></icon></a>
                <a href="javascript:delete_company({$l_val['company_id']})" title="删除"><icon class="icon-trash" ></icon></a>
            </td>
        </tr>
    </foreach>
</table>
<script>
    $(function () {

        $('#addnew').click(function(){

            window.location.href="{:U('Contract/add')}";
        });
    });

    function delete_company(id)
    {

        if(confirm("确定要删除吗？"))
        {
            $.get("{:U('Company/delete',array('cid'=>$l_val['company_id']))}",function (xhr) {
                if(200 == xhr.status){
                    alert(xhr.msg);
                    window.location.href="{:U('Company/Index')}";
                }else{
                    alert(xhr.msg);
                }
            });
        }
    }
</script>

<include file="Public:footer" />

